package Vocabulary;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

public class WebCrawler {
    public static void main(String[] args) {
        String url = "https://word.iciba.com/?action=words&class=11&course=1";
        Map<String, String> headers = new HashMap<>();
        headers.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299");

        try {
            Document doc = Jsoup.connect(url).headers(headers).get();
            Elements examStar = doc.getElementsByClass("word_footer_test_l");

            // 获取onclick事件的值
            Element element = examStar.get(0).child(3);
            String onclickValue = element.attr("onclick");

            System.out.println(onclickValue);

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
